<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAccountLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('account_logs', function (Blueprint $table) {
            $table->increments('id')->comment('账户日志ID');
            $table->unsignedInteger('user_id')->comment('用户ID');
            $table->unsignedInteger('coin_id')->comment('币种ID');
            $table->string('type')->comment('操作：充值到账，提现申请，提币通过，提币撤销，租赁，托管，续费，退款，空间租赁推荐奖励，运维费推荐奖励，系统充值，系统扣除，静态奖励释放，推荐奖励释放，领导奖励释放');
            $table->enum('account_type',['available','disabled', 'freeze'])->comment('资产类型');
            $table->unsignedInteger('action_id')->nullable()->default(null)->comment('操作对应记录ID');
            $table->unsignedDecimal('before', 20, 8)->nullable()->comment('操作前数量');
            $table->decimal('number', 20, 8)->comment('操作数量');
            $table->unsignedDecimal('after', 20, 8)->nullable()->comment('操作后数量');
            $table->integer('version')->default(0)->comment('版本号');
            $table->timestamp('time')->nullable()->useCurrent()->comment('时间');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('account_logs');
    }
}
